<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<title>Site Administration</title>
    <link rel="stylesheet" href="<?php echo get_installed_path() ?>/css/forms.css" type="text/css" media="screen" title="no title" charset="utf-8" />
    <link rel="stylesheet" href="<?php echo get_installed_path() ?>/css/admin.css" type="text/css" media="screen" title="no title" charset="utf-8" />    
     <script src="<?php echo get_installed_path() ?>/js/admin.js" type="text/javascript" language="javascript" charset="utf-8"></script>
     <script type="text/javascript" charset="utf-8">
        // tinymce callback
        function pixelFileBrowser (field_name, url, type, win) {
            var picker_url;
            if (type=="file") {
                picker_url = '<?php echo get_installed_path(); ?>/admin/pages/js_list';
            } else {
                picker_url = '<?php echo get_installed_path(); ?>/admin/files/browse' + "?files_filter_by=" + type;
            }
           tinyMCE.openWindow({
               file : picker_url,
               title : "File Browser",
               width : 600,  
               height : 400,
               close_previous : "no"
           }, {
               window : win,
               input : field_name,
               resizable : "yes",
               inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
               editor_id : tinyMCE.getWindowArg("editor_id")
           });
           return false;
         }
     </script>
    <style type="text/css" media="screen">
    body {
        text-align:left;
        background:#f3f3f3;       
    }
    p {
        padding:0.5em;
    }
        
    </style>
</head>
<body>
<?php

    if ( !empty($content) )
    {
        echo form_tag('edit_content_area').
             hidden_field_tag('id',$content->get('id')).
             hidden_field_tag('page_id',$content->get('page_id')).
             hidden_field_tag('action','edit_content');
        
        // switch type of field 
        $is_html = false;    
        switch ($content->get('section_type')) {
            case 'html':
                echo text_area_tag('content',$content->get('content'),array('size'=>'50x25','id'=>'content')).'<br>';
                $is_html = true;
                break;
            case 'text':
                echo '<p><b>Content</b> (all html will be stripped): <br>'.
                     text_field_tag('content',$content->get('content'),array('size'=>'50','id'=>'content','style'=>'width:80%')).
                     '</p><br>';
                break;
            case 'textarea':
                echo '<p><b>Content</b> (all html will be stripped): <br>'.
                text_area_tag('content',$content->get('content'),array('size'=>'50x25','id'=>'content','style'=>'width:80%')).
                '</p><br>';
                break;
            default:
                echo text_area_tag('content',$content->get('content'),array('size'=>'50x25','id'=>'content')).'<br>';
                $is_html = true;
                break;
        }
        
        
        
        echo content_tag('p',submit_tag('Save Edit').
                            submit_tag('Cancel Edit',
                                array(
                                    'confirm'=>'Are you sure you want to cancel the edit? All your changes will not be saved.',
                                    'name'=>'cancel',
                                    'class'=>'submit_delete'
                                    )
                                      )
                        ).
             end_form_tag();
    }
    if ($is_html) create_editor_instance('content',array('all_elements'=>true));
?>
</body>
</html>